<template>
  <div class="homeSwipe">
    <van-search class="my-search" v-model="mysearch" shape="round" placeholder="搜索关键词"></van-search>
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in bannerData" :key="item.id">
        <img :src="item.picUrl" />
      </van-swipe-item>
    </van-swipe>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "homeSwipe",
  props: {
    msg: String
  },

  data() {
    return {
      mysearch: "",
      bannerData: []
    };
  },

  created() {
    this.getBanner();
  },

  methods: {
    getBanner() {
      axios
        .get("/api/recommend/banner", "")
        .then(res => {
          // console.log(res.data.data);
          this.bannerData = res.data.data;
        })
        .catch(err => {
          console.error(err);
        });
    },
    mounted() {}
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.homeSwipe {
  padding-top: 60px;
  background-color: #fafafa;
}
.my-search {
  background-color: #fafafa;
  padding: 15px;
}
.my-search .van-search__content {
  box-shadow: 0 0px 25px rgb(0 0 0 / 5%);
}
.my-swipe {
  padding-top: 10px;
}
.my-swipe .van-swipe-item {
  width: 100%;
}
.van-swipe-item img {
  width: calc(100% - 30px);
  border-radius: 0.5rem;
  text-align: center;
}
.van-search__content {
  background: #fff;
}
</style>
